package de.davidneu.gpxviewer.speedprofile
{
	import de.davidneu.gpx.GpxTrack;
	import de.davidneu.gpx.GpxTrackPoint;
	import de.davidneu.gpxviewer.heightProfile.ProfileRenderer;
	import flash.geom.Point;


	/**
	 * @author David Neu
	 */
	public class ProfileSpeedRenderer extends ProfileRenderer
	{
		public function ProfileSpeedRenderer(w : Number, h : Number, t : GpxTrack, minElevation : Number, maxElevation : Number, lineColor : Number, lineThicknes : Number, lineAlpha : Number, bgColor : Number, bgAlpha : Number)
		{
			super(w, h, t, minElevation, maxElevation, lineColor, lineThicknes, lineAlpha, bgColor, bgAlpha);
		}
		
		override public function getPointPosition(p : GpxTrackPoint) : Point
        {
            if (_mode == MODE_DISTANCE) {
                return new Point(p.distance/_t.distance * _width, (p.averageSpeed(20) - _minElevation) / _profileElevation * _height);
            }
            if (_mode == MODE_TIME) {
            	return new Point(p.relativeTime/_t.time * _width, (p.averageSpeed(20) - _minElevation) / _profileElevation * _height);
            }
            return null;
        }
	}
}
